﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Cobit5.Web.MemberShip
{
    public partial class CreateMember : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button_CheckUserId_Click(object sender, EventArgs e)
        {
            Label_CheckUserIdResult.Text = "";
            TextBox_UserId.BorderColor = System.Drawing.Color.Gray;

            if (TextBox_UserId.Text.Length < 1)
                TextBox_UserId.BorderColor = System.Drawing.Color.Red;
            else
            {
                int ok = Cobit5.BIZ.MemberShip.Membership.ExistMembership(TextBox_UserId.Text.Trim());
                if (ok == 0) Label_CheckUserIdResult.Text = TextBox_UserId.Text + "不存在，可以注册";
                else Label_CheckUserIdResult.Text = TextBox_UserId.Text + "存在，请更换";
            }
        }

        protected void Button_SubmitNewUser_Click(object sender, EventArgs e)
        {
            //int ok = BIZ.Membership.CreateMembership(TextBox_UserId.Text.Trim(),TextBox_UserName.Text.Trim(),TextBox_Password.Text.Trim(), TextBox_Birthday.Text, TextBox_Email.Text.Trim(), TextBox_Mobile.Text.Trim(), TextBox_Telephone.Text.Trim(), TextBox_PasswordQuestion.Text.Trim(), TextBox_PasswordAnswer.Text.Trim(), DropDownList_Comment.SelectedItem.Value);
            int ok = Cobit5.BIZ.MemberShip.Membership.CreateMembership(TextBox_UserId.Text.Trim(), TextBox_UserName.Text.Trim(), TextBox_Password.Text.Trim(), TextBox_Birthday.Text.Trim(), TextBox_Email.Text.Trim(), TextBox_Mobile.Text.Trim(), TextBox_Telephone.Text.Trim(), TextBox_PasswordQuestion.Text.Trim(), TextBox_PasswordAnswer.Text.Trim(), DropDownList_Comment.SelectedItem.Value);
            switch (ok)
            {
                case 1: Response.Redirect("CreateMemberDone.aspx?newuserid=" + TextBox_UserId.Text.Trim()); break;
                case 2: Label_Result.Text = "该用户Id已被注册，请更换Id"; break;
                case 3: Label_Result.Text = "生日日期不争取，请核实修改"; break;
                case 4: Label_Result.Text = "系统内部问题，请与管理员联系"; break;
            }
        }
    }
}